﻿<%@ Page Title="Player Detail" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="PlayerDetail.aspx.vb" Inherits="WSAD_Assignment.PlayerDetail" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .noratingpng
            {
                background-image: url('../Images/norating.png');
                width: 32px;
                height: 32px;
            }

            .ratingpng
            {
                background-image: url('../Images/rating.png');
                width: 32px;
                height: 32px;
            }

            .doneratingpng
            {
                background-image: url('../Images/rating.png');
                width: 32px;
                height: 32px;
            }
       </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    
    <h3 class="form-signup-heading">Player Profile: <asp:Label ID="lblPlayerName" runat="server"></asp:Label></h3>
    
    <asp:UpdatePanel id="upHeaderButtons" runat="server">
        <ContentTemplate>

            <asp:LinkButton ID="btnPlayerLike" 
                    runat="server"
                    CssClass="btn btn-primary cancel"    
                    CausesValidation="false"      
                    OnClick="btnPlayerLike_Click">
                    <i aria-hidden="true" class="glyphicon glyphicon-thumbs-up"></i> Like
            </asp:LinkButton>

            <asp:LinkButton ID="btnPlayerUnlike" 
                    runat="server"
                    CssClass="btn btn-primary cancel"   
                    CausesValidation="false"       
                    OnClick="btnPlayerUnlike_Click">
                    <i aria-hidden="true" class="glyphicon glyphicon-thumbs-down"></i> Unlike
            </asp:LinkButton>

             <asp:LinkButton ID="btnEditPlayer" 
                    runat="server"
                    CssClass="btn btn-primary cancel"  
                    CausesValidation="false"      
                    OnClick="btnEditPlayer_Click">
                    <i aria-hidden="true" class="glyphicon glyphicon-pencil"></i> Edit Player
            </asp:LinkButton>
    
            <asp:LinkButton ID="btnPlayerViews" 
                    runat="server"
                    CssClass="btn btn-success"    
                    Enabled="false"
                    CausesValidation="false">
                    <i aria-hidden="true" class="glyphicon glyphicon-eye-open"></i>  <asp:Label ID="lblPlayerViews" runat="server"></asp:Label> 
            </asp:LinkButton>

             <asp:LinkButton ID="btnBackClubPlayers" 
                    runat="server"
                    CssClass="btn btn-default cancel"
                    CausesValidation="false"    
                    OnClick="btnBackClubPlayers_Click">
                    <i aria-hidden="true" class="glyphicon glyphicon-arrow-left"></i> Back to Club Players
            </asp:LinkButton><br /><br />

            <asp:Panel ID="pnlPlayerLikes" runat="server"><asp:Label ID="lblPlayerLikes" runat="server"></asp:Label></asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
    <p>
        <asp:DetailsView ID="dvPlayerDetail" runat="server" AutoGenerateRows="False" DataSourceID="PlayerListDataSource" GridLines="None"
            CssClass="table table-hover table-striped table-bordered table-condensed">
            <Fields>
                <asp:ImageField DataImageUrlField="ProfilePicture" HeaderText="Profile Picture">
                    <ControlStyle Height="100px" Width="100px" />
                </asp:ImageField>
                <asp:BoundField DataField="FullName" HeaderText="Full Name" SortExpression="FullName" />
                <asp:BoundField DataField="ClubName" HeaderText="Club" SortExpression="ClubName" />
                <asp:BoundField DataField="DateOfBirth" HeaderText="Date of Birth" SortExpression="DateOfBirth" DataFormatString="{0:dd/MM/yyyy}" />
                <asp:BoundField DataField="CountryName" HeaderText="Nationality" SortExpression="CountryName" />
                <asp:BoundField DataField="Height" HeaderText="Height" SortExpression="Height" />
                <asp:BoundField DataField="Weight" HeaderText="Weight" SortExpression="Weight" />
                <asp:BoundField DataField="PositionName" HeaderText="Position" SortExpression="PositionName" />
                <asp:BoundField DataField="PreferredFoot" HeaderText="Preferred Foot" SortExpression="PreferredFoot" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="PlayerListDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsConnectionString %>" ProviderName="<%$ ConnectionStrings:ClubsConnectionString.ProviderName %>" SelectCommand="SELECT [FullName], [ClubName], [DateOfBirth], [CountryName], [Height], [Weight], [PositionName], [PreferredFoot], [ProfilePicture], [Players.ID] AS PlayerID, [Clubs.ID] AS ClubID FROM [PlayerList] WHERE ([Players.ID] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="ID" QueryStringField="PlayerID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

    </p>    
    <p>
        <asp:DetailsView ID="dvHiddenClubID" runat="server" AutoGenerateRows="False" DataSourceID="PlayerListDataSource2" Height="50px" Visible="False" Width="125px" DataKeyNames="ClubID">
            <Fields>
                <asp:BoundField DataField="ClubID" HeaderText="ClubID" SortExpression="ClubID" InsertVisible="False" ReadOnly="True" />
            </Fields>
        </asp:DetailsView>
    </p>
    <p>

        <asp:SqlDataSource ID="PlayerListDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsConnectionString %>" ProviderName="<%$ ConnectionStrings:ClubsConnectionString.ProviderName %>" SelectCommand="SELECT [Clubs.ID] AS ClubID FROM [PlayerList] WHERE ([Players.ID] = ?)">
            <SelectParameters>
                <asp:QueryStringParameter Name="ClubID" QueryStringField="PlayerID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>

    <br />
            <div class="tabbable">
                <ul class="nav nav-tabs" id="playerTabs">
                    <li class="active"><a href="#ratings" data-toggle="tab">Ratings</a></li>
                    <li><a href="#tags" data-toggle="tab">Tags</a></li>
                    <li><a href="#comments" data-toggle="tab">Comments</a></li>
                </ul>

                <div class="tab-content">
                    <div id="ratings" class="tab-pane active">           
                        <asp:UpdatePanel id="upRatings" runat="server">
                            <ContentTemplate>      
                                <asp:Panel ID="pnlRating" CssClass="pnlAnonymous" runat="server">
                                    <b><asp:Label ID="lblRating" runat="server">
                                        <asp:LinkButton ID="btnSignIn_Rate" 
                                            runat="server"
                                            CssClass="btn btn-primary btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnSignIn_Rate_Click">Sign In
                                        </asp:LinkButton>
            
                                        or 

                                        <asp:LinkButton ID="btnRegister_Rate" 
                                            runat="server"
                                            CssClass="btn btn-success btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnRegister_Rate_Click">Register
                                        </asp:LinkButton></asp:Label></b>
                                </asp:Panel>

                                <asp:PlaceHolder ID="phRatings" runat="server">
                                    <b><asp:Label ID="lblRatePlayer" runat="server">Rate this Player!</asp:Label></b><br /><br />
                                    <asp:Rating ID="RatingForPlayer" runat="server" AutoPostBack="true" EmptyStarCssClass="noratingpng" 
                                        OnChanged="RatingForPlayer_Changed" FilledStarCssClass="ratingpng" StarCssClass="ratingpng" WaitingStarCssClass="doneratingpng">
                                    </asp:Rating>
                                    <br /><br />
                                    <asp:Label ID="lblRatingDone" runat="server"></asp:Label>
                                </asp:PlaceHolder>
                            
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>

                    <div id="tags" class="tab-pane">
                        <asp:UpdatePanel id="upTags" runat="server">
                            <ContentTemplate>

                                <asp:Panel ID="pnlTagAnonymous" CssClass="pnlAnonymous" runat="server">
                                    <b><asp:Label ID="lblTagAnonymous" runat="server">
                                        <asp:LinkButton ID="btnSignIn_Tag" 
                                            runat="server"
                                            CssClass="btn btn-primary btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnSignIn_Tag_Click">Sign In
                                        </asp:LinkButton>
            
                                        or 

                                        <asp:LinkButton ID="btnRegister_Tag" 
                                            runat="server"
                                            CssClass="btn btn-success btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnRegister_Tag_Click">Register
                                        </asp:LinkButton></asp:Label></b>
                                </asp:Panel>

                                <asp:PlaceHolder ID="phTags" runat="server">
                                    <div class="form-group tags">
                                        <div class="form-group-tags">
                                            <asp:CheckBoxList ID="cblTags" runat="server" DataTextField="TagName" DataValueField="ID" RepeatDirection="Horizontal" RepeatColumns="8"></asp:CheckBoxList>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <%--<asp:Label ID="lblTags" AssociatedControlID="txtTags" runat="server" CssClass="col-sm-3 control-label" Text="More Tags"></asp:Label>--%>

                                        <div class="col-sm-5">
                                            <asp:TextBox ID="txtTags" name="txtTags" runat="server" CssClass="form-control" placeholder="Add More Tags (separated by commas)"></asp:TextBox>
                                        </div>
        
                                        <asp:LinkButton ID="btnTagPlayer" 
                                            runat="server"
                                            CssClass="btn btn-success cancel"    
                                            OnClick="btnTagPlayer_Click"
                                            CausesValidation="False">
                                            <i aria-hidden="true" class="glyphicon glyphicon-tag"></i>  Tag Player
                                        </asp:LinkButton><br /><br />
                                        <b><asp:Label ID="lblTaggingDone" runat="server"></asp:Label></b>

                                    </div>
                                </asp:PlaceHolder>

                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>

                    <div id="comments" class="tab-pane">
                        <asp:UpdatePanel id="upComments" runat="server">
                            <ContentTemplate>
                                <asp:Panel ID="pnlCommentAnonymous" CssClass="pnlAnonymous" runat="server">
                                    <b><asp:Label ID="lblCommentAnonymous" runat="server">
                                        <asp:LinkButton ID="btnSignIn_Comment" 
                                            runat="server"
                                            CssClass="btn btn-primary btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnSignIn_Comment_Click">Sign In
                                        </asp:LinkButton>
            
                                        or 

                                        <asp:LinkButton ID="btnRegister_Comment" 
                                            runat="server"
                                            CssClass="btn btn-success btn-sm cancel"    
                                            CausesValidation="false"      
                                            OnClick="btnRegister_Comment_Click">Register
                                        </asp:LinkButton></asp:Label></b>
                                </asp:Panel>

                                <asp:PlaceHolder ID="phComments" runat="server">
                                    <div class="form-group">
                                        <asp:Label ID="lblUsername" AssociatedControlID="txtUsername" runat="server" CssClass="col-sm-2 control-label" Text="Username"></asp:Label>

                                        <div class="col-sm-4">
                                            <asp:TextBox ID="txtUsername" name="txtUsername" runat="server" CssClass="form-control" placeholder="Username" Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <asp:Label ID="lblTitle" AssociatedControlID="txtTitle" runat="server" CssClass="col-sm-2 control-label" Text="Title"></asp:Label>

                                        <div class="col-sm-4">
                                            <asp:TextBox ID="txtTitle" name="txtTitle" runat="server" CssClass="form-control" placeholder="Title"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle" Display="Dynamic" CssClass="field-validation-error" ErrorMessage="This is a required field!" />
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtTitle" Display="Dynamic" ErrorMessage="This field must be between 5 and 30 characters long!"
                                                    CssClass="field-validation-error" ValidationExpression="^[a-zA-Z0-9'@&#.,\s]{5,30}$" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <asp:Label ID="lblComment" AssociatedControlID="txtComment" runat="server" CssClass="col-sm-2 control-label" Text="Comment"></asp:Label>

                                        <div class="col-sm-4">
                                            <asp:TextBox ID="txtComment" name="txtComment" runat="server" CssClass="form-control" placeholder="Comment" TextMode="MultiLine" Height="100px"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtComment" Display="Dynamic" CssClass="field-validation-error" ErrorMessage="This is a required field!" />
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtComment" Display="Dynamic" ErrorMessage="This field must be between 5 and 300 characters long!"
                                                    CssClass="field-validation-error" ValidationExpression="^[a-zA-Z0-9'@&#.,\s]{5,300}$" />
                                        </div>
                                    </div>
                    
                                    <br /><br /><br /><br />
                    
                                    <div class="form-group">
                                        <asp:LinkButton ID="btnAddComment" 
                                            runat="server"
                                            CssClass="btn btn-success"    
                                            OnClick="btnAddComment_Click"
                                            CausesValidation="True">
                                            <i aria-hidden="true" class="glyphicon glyphicon-comment"></i>  Add Comment
                                        </asp:LinkButton>
                                    </div>    
 
                                </asp:PlaceHolder>

                                <asp:GridView ID="gvPlayerComments" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                                    CssClass="table table-hover table-striped table-bordered table-condensed">
                                    <Columns>
                                        <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                                        <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                                        <asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" />
                                    </Columns>
                                </asp:GridView>

                            </ContentTemplate>
                    </asp:UpdatePanel>
               </div>
            </div>
        </div>

    <br />
    
<%--    <p>
        <asp:PlaceHolder ID="phNoComments" runat="server" Visible="false">No comments were added for this player yet!</asp:PlaceHolder>
    </p>--%>
<%--    <p>
        <strong>Add your comment here: </strong>
    </p>--%>

</asp:Content>
